package com.itheima.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * <h1>swagger</h1>
 *
 * @author <a href="515857087@qq.com">叶世铭</a>
 * @version 1.0.0
 * @since 2022/10/03
 */
@Configuration
@EnableSwagger2
@EnableKnife4j
public class Swagger2Config {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                //请求路径
                .pathMapping("/")
                .select()
                //作用范围,在那个包下
                .apis(RequestHandlerSelectors.basePackage("com.itheima"))
                //指定包下所有请求
                .paths(PathSelectors.any())
                .build().apiInfo(new ApiInfoBuilder()
                        //标题
                        .title("backend-API文档")
                        //描述
                        .description("本文档描述了backend接口定义")
                        //版本
                        .version("v1.0")
                        .build());
    }

}
